package com.webull.information.center.dao;

import java.util.List;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Repository;

/**
 * 新闻Dao
 *
 * @author shimingjun
 * @version 1.0
 * @date 2016年6月2日 下午5:08:52
 * @since JDK 1.8
 */
@Repository
public class InfoTickerDao {

	protected final Logger logger = LogManager.getLogger(getClass());

	private @Autowired JdbcTemplate jdbcTemplate;
	private @Autowired NamedParameterJdbcTemplate namedParameterJdbcTemplate;

	private @Autowired DbShardHelper dbShardHelper;

	/**
	 * 根据新闻ID获取相关联股票列表
	 *
	 * @author shimingjun
	 * @since 0.1.0
	 */
	public List<Integer> searchStocksByNewId(Long newsId) {
		return jdbcTemplate.queryForList(dbShardHelper.shardDealSql(Sql.STOCKSBYNEWID, newsId), Integer.class, newsId);
	}

	private class Sql {

		private static final String STOCKSBYNEWID = "select  t2.ticker_id from  wli_news_ticker_rel t2 where t2.news_id = ? and t2.del = 0 order by id desc limit 10";

	}

}
